﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MulticastTV
{

    /// <summary>
    /// OSD settings form
    /// </summary>
 
    public partial class OsdSettings : Form
    {
        public OsdSettings()
        {
            InitializeComponent();
        }

        private void OsdSettings_Load(object sender, EventArgs e)
        {
            numericUpDown1.Value = Properties.Settings.Default.OSDYposition;
            numericUpDown2.Value = Properties.Settings.Default.OSDXposition;
            numericUpDown3.Value = Properties.Settings.Default.OSDTImeout;
            numericUpDown4.Value = (decimal)Properties.Settings.Default.OsdSizeFactor;

            numericUpDown5.Value = Properties.Settings.Default.EPGPopUpHeight;
            numericUpDown6.Value = Properties.Settings.Default.EPGpopupYOffset;
            numericUpDown9.Value = Properties.Settings.Default.EPGPopUpTimeOut;
            numericUpDown10.Value = Properties.Settings.Default.EpgPopUpXOffset;
            numericUpDown11.Value = Properties.Settings.Default.EpgPopUpWidthPercent;
            
            numericUpDown8.Value = Properties.Settings.Default.EPGverticalOffset;
            numericUpDown7.Value = Properties.Settings.Default.EPGhorizontalOffset;
            numericUpDown15.Value = Properties.Settings.Default.EPGDetailsTableFontSize;
            numericUpDown14.Value = Properties.Settings.Default.EPGDetailsTableRowSize;
            numericUpDown13.Value = Properties.Settings.Default.EPGDetailsFontSize;
            numericUpDown12.Value = Properties.Settings.Default.EPGDetailsWidth;

            if (Properties.Settings.Default.EpgPopUpAlign == "left")
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (Properties.Settings.Default.EpgPopUpAlign == "center")
            {
                comboBox1.SelectedIndex = 1;
            }
            else if (Properties.Settings.Default.EpgPopUpAlign == "right")
            {
                comboBox1.SelectedIndex = 2;
            }
        }

        private void saveSettings()
        {
            Properties.Settings.Default.OSDXposition = (int)numericUpDown2.Value;
            Properties.Settings.Default.OSDYposition = (int)numericUpDown1.Value;
            Properties.Settings.Default.OSDTImeout = (int)numericUpDown3.Value;
            Properties.Settings.Default.OsdSizeFactor = (float)numericUpDown4.Value;

            Properties.Settings.Default.EPGPopUpHeight = (int)numericUpDown5.Value;
            Properties.Settings.Default.EPGpopupYOffset = (int)numericUpDown6.Value;
            Properties.Settings.Default.EPGPopUpTimeOut = (int)numericUpDown9.Value;
            Properties.Settings.Default.EpgPopUpXOffset = (int)numericUpDown10.Value;
            Properties.Settings.Default.EpgPopUpWidthPercent = (int)numericUpDown11.Value;
            
            Properties.Settings.Default.EPGverticalOffset = (int)numericUpDown8.Value;
            Properties.Settings.Default.EPGhorizontalOffset = (int)numericUpDown7.Value;
            Properties.Settings.Default.EPGDetailsTableFontSize = (int)numericUpDown15.Value;
            Properties.Settings.Default.EPGDetailsTableRowSize = (int)numericUpDown14.Value;
            Properties.Settings.Default.EPGDetailsFontSize = (int)numericUpDown13.Value;
            Properties.Settings.Default.EPGDetailsWidth = (int)numericUpDown12.Value;

            
            if (comboBox1.SelectedIndex == 0)
            {
                Properties.Settings.Default.EpgPopUpAlign = "left";
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                Properties.Settings.Default.EpgPopUpAlign = "center";
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                Properties.Settings.Default.EpgPopUpAlign = "right";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            saveSettings();
            this.Close();
        }
    }
}
